package triangle;

public class Triangle {
	private Point a= new Point();
	private Point b= new Point();
	private Point c= new Point();
   public Triangle(){
	   a=new Point();
	   b=new Point();
	   c=new Point();
	   
   }
	public Triangle(Point x,Point y,Point z){
    	x=a;
    	y=b;
    	z=c;
    }
	
	public double round(double x,int n){
		x=x*Math.pow(10, n);
		x=Math.round(x);		
		x=x/Math.pow(10, n);
				return x;
		
	}
	
	
	public double area(){
		double s,p;
		p=(a.comDistance(b)+b.comDistance(a)+b.comDistance(c))/2;
		s=Math.sqrt(p*(p-a.comDistance(b))*(p-b.comDistance(a))*(p-b.comDistance(c)));
		return round(s,3);
		
	}
	public boolean checkPoint(Point d){
	   double s1=round(d.areaTriangle(b, c),1);
	   double s2=round(d.areaTriangle(a, b),1);
	   double s3=round(d.areaTriangle(a, c),1);
	   double s4=round(a.areaTriangle(b, c),1);
		
		if ( s1+s2+s3 > s4 ) return false;
		
		else return true;
	}
    
public static void main(String[] args) {
	
	Triangle n= new Triangle();
	n.a.input();
	n.b.input();
	n.c.input();
	if(n.area()>0){System.out.println("Area of triangle ABC:"+n.area());
	Point d= new Point();
	System.out.println("Enter Point D:");
	d.input();
	if(n.checkPoint(d)) System.out.println("The point inside the triangle");
	else System.out.println("The point outside the triangle");
	}
	else System.out.println("ABC isn't a triangle");
	   
	
}
}